package com.myres.model;

import java.sql.Connection;
import java.sql.PreparedStatement;

import com.myres.db.ConnectionPool;
import com.myres.util.IpTool;
import java.sql.SQLException;
public class VisitLogView extends VisitLog{
	private String province;
	private String city;
	private String ipString;
	public String getProvince() {
		return province;
	}
	public void setProvince(String province) {
		this.province = province;
	}
	public String getCity() {
		return city;
	}
	public void setCity(String city) {
		this.city = city;
	}
	public String getIpString(){
		return ipString=IpTool.long2Ip(this.getIp());
	}
	public int save() throws SQLException{
		Connection con=ConnectionPool.getPool().getConnection();
		PreparedStatement pstmt=con.prepareStatement(
				"insert into res_visitlog( _visitor,_ip,_page,_referer,_province,_city) values(?,?,?,?,?,?)" );
		pstmt.setString(1, this.getPerson());
		pstmt.setLong(2, this.getIp());
		pstmt.setString(3, this.getPage());
		pstmt.setString(4, this.getReferer());
		pstmt.setString(5, this.getProvince());
		pstmt.setString(6, this.getCity());
		int result=pstmt.executeUpdate();
		con.close();
		return result;
	}

}
